package com.zndroid.timePicker;

import android.view.Gravity;

import androidx.fragment.app.FragmentActivity;

import com.zndroid.timePicker.impl.PickerDialog;
import com.zndroid.timePicker.impl.PickerType;

import static com.zndroid.timePicker.impl.PickerType.COMMON;

public class TimerPicker {
    /**
     * 常用
     * */
    public static void show(FragmentActivity activity, PickerDialog.OnDateResultListener listener) {
        show(activity, COMMON, Gravity.BOTTOM, true, 0, 0, listener);
    }

    public static void show(FragmentActivity activity, @PickerType int pickerType, int gravity, boolean canceledOnTouchOutside, PickerDialog.OnDateResultListener listener) {
        show(activity, pickerType, gravity, canceledOnTouchOutside, 0, 0, listener);
    }

    public static void show(FragmentActivity activity, @PickerType int pickerType, int gravity, boolean canceledOnTouchOutside, int minYear, int maxYear, PickerDialog.OnDateResultListener listener) {
        PickerDialog.Builder builder = new PickerDialog.Builder(activity)
                .setGravity(gravity)
                .set12HourModel(false)
                .setPickType(pickerType)
                .setCanceledTouchOutside(canceledOnTouchOutside)
                .setOnDateResultListener(listener)
                .setYearRang(minYear, maxYear);
        show(activity, builder);
    }

    public static void show(FragmentActivity activity, PickerDialog.Builder builder) {
        builder.build().show(activity.getSupportFragmentManager(), "TimerPicker");
    }
}
